package com.ibeeking.found.content.api.feign.fallback;

import com.ibeeking.found.content.api.common.dto.GoodsDTO;
import com.ibeeking.found.content.api.feign.ContentGoodsBClient;
import com.ibeeking.nematos.utils.data.Collections3;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class ContentGoodsBFallbackFactory implements FallbackFactory<ContentGoodsBClient> {
    @Override
    public ContentGoodsBClient create(Throwable throwable) {
        return new ContentGoodsBClient() {

            @Override
            public ResponseResult<List<GoodsDTO>> listByGoods(List<Long> goodsIds) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询商品信息失败", Collections3.emptyList());
            }

        };
    }
}
